package nl.fotoniq.android.lockpicker.shared;

import android.database.ContentObserver;
import android.os.Handler;

/**
 * The Class LockPickerObserver.
 * <p>
 * Notifies a handler when the lock setting value is changed.
 * </p>
 * 
 * @author jeroen.brosens
 */
public class LockPickerObserver extends ContentObserver {

	/** The Constant LOCK_SETTING_CHANGED_MESSAGE. */
	public static final int LOCK_SETTING_CHANGED_MESSAGE = 0;

	private Handler handler;

	/**
	 * Instantiates a new LockPickerObserver.
	 * 
	 * @param handler
	 *            the handler
	 */
	public LockPickerObserver(Handler handler) {
		super(handler);

		this.handler = handler;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see android.database.ContentObserver#onChange(boolean)
	 */
	@Override
	public void onChange(boolean selfChange) {
		super.onChange(selfChange);

		LockPickerUtil.log_d("Observed lock setting change");

		handler.sendEmptyMessage(LOCK_SETTING_CHANGED_MESSAGE);
	}
}